package com.ruoyi.signup.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.signup.domain.ActivitySignup;
import com.ruoyi.signup.service.IActivitySignupService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动报名Controller
 * 
 * @author anyunyi
 * @date 2025-05-29
 */
@RestController
@RequestMapping("/signup/dept")
public class ActivitySignupController extends BaseController
{
    @Autowired
    private IActivitySignupService activitySignupService;

    /**
     * 查询活动报名列表
     */
    @PreAuthorize("@ss.hasPermi('signup:dept:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivitySignup activitySignup)
    {
        startPage();
        List<ActivitySignup> list = activitySignupService.selectActivitySignupList(activitySignup);
        return getDataTable(list);
    }

    /**
     * 导出活动报名列表
     */
    @PreAuthorize("@ss.hasPermi('signup:dept:export')")
    @Log(title = "活动报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivitySignup activitySignup)
    {
        List<ActivitySignup> list = activitySignupService.selectActivitySignupList(activitySignup);
        ExcelUtil<ActivitySignup> util = new ExcelUtil<ActivitySignup>(ActivitySignup.class);
        util.exportExcel(response, list, "活动报名数据");
    }

    /**
     * 获取活动报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('signup:dept:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(activitySignupService.selectActivitySignupById(id));
    }

    /**
     * 新增活动报名
     */
    @PreAuthorize("@ss.hasPermi('signup:dept:add')")
    @Log(title = "活动报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitySignup activitySignup)
    {
        return toAjax(activitySignupService.insertActivitySignup(activitySignup));
    }

    /**
     * 修改活动报名
     */
    @PreAuthorize("@ss.hasPermi('signup:dept:edit')")
    @Log(title = "活动报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivitySignup activitySignup)
    {
        return toAjax(activitySignupService.updateActivitySignup(activitySignup));
    }

    /**
     * 删除活动报名
     */
    @PreAuthorize("@ss.hasPermi('signup:dept:remove')")
    @Log(title = "活动报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activitySignupService.deleteActivitySignupByIds(ids));
    }
}
